package com.baixun.gassystem.service;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONObject;
import com.baixun.gascommon.utils.RedisUtils;
import com.baixun.gascommon.config.ApiConfig;
import com.baixun.gascommon.utils.HttpClientUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import java.net.HttpURLConnection;
import java.nio.charset.StandardCharsets;
import java.util.*;

/**
 * @program: 上海燃气驾驶舱
 * @description: 负责调用evs具体的接口
 * @author: yesong
 **/

@Service
public class ApiService {

    @Autowired
    private  RedisUtils redisUtils;

    private static final String TOKEN_KEY = "SAAS_SESSION_TOKEN";


    // 每7天自动获取 token，并存储到 Redis，token 默认有效期为7天
    @Scheduled(fixedRate = 29 * 60 * 1000) // 每29分钟执行一次
    public void refreshToken() {
        try {
            String token = getAuthToken(); // 获取新的 token
            System.out.println("Token before storing in Redis: " + token);
            if (token != null) {
                redisUtils.set(TOKEN_KEY, token, 30 * 60L); // 存储 token，设置过期时间为7天（单位：秒）
                System.out.println("Token refreshed and stored in Redis: " + token);
                // 从 Redis 中读取 token 并打印
                String storedToken = redisUtils.get(TOKEN_KEY);
                System.out.println("Token after storing in Redis: " + storedToken);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    // 从 Redis 中获取 token
    public  String getTokenFromRedis() {
        return redisUtils.get(TOKEN_KEY);
    }


    // 调用 POST 登录接口并返回 SAAS_SESSION token
    public String getAuthToken() throws Exception {
        String loginUrl = ApiConfig.DOMAIN + ApiConfig.LOGIN_API;

        // 构建 Authorization 验证字符串
        String base64String = ApiConfig.USERNAME + ApiConfig.API_SECRET + ApiConfig.PASSWORD;
        String encodedAuth = Base64.getEncoder().encodeToString(base64String.getBytes(StandardCharsets.UTF_8));

        // 请求头信息
        HashMap<String, String> headers = new HashMap<>();
        headers.put("Authorization", encodedAuth);  // 将 Base64 编码的字符串放入 Authorization 头
        headers.put("Content-Type", "application/json; charset=UTF-8");

        // 构建登录请求体
        String loginPayload = "{\"username\": \"" + ApiConfig.USERNAME + "\", " +
                "\"password\": \"" + ApiConfig.PASSWORD + "\", " +
                "\"verificationCode\": \"" + ApiConfig.VERIFICATION_CODE + "\", " +
                "\"verificationCodeToken\": \"" + ApiConfig.VERIFICATION_TOKEN + "\"}";

        // 调用 POST 登录接口并获取响应
        HttpURLConnection connection = HttpClientUtil.sendPostRequest(loginUrl, headers, loginPayload);

        // 获取响应码并检查请求是否成功
        int responseCode = connection.getResponseCode();
        System.out.println("Response Code: " + responseCode);

        if (responseCode == HttpURLConnection.HTTP_OK) {
            // 获取响应中的 Set-Cookie，提取 SAAS_SESSION token
            Map<String, List<String>> headerFields = connection.getHeaderFields();
            for (Map.Entry<String, List<String>> entry : headerFields.entrySet()) {
                for (String value : entry.getValue()) {
                    if (value.startsWith("SAAS_SESSION=")) {
                        // 提取并返回 token
                        String token = value.split(";")[0].split("=")[1];
                        System.out.println("SAAS_SESSION token: " + token);
                        return token;
                    }
                }
            }
        } else {
            System.out.println("POST request failed with response code: " + responseCode);
        }

        System.out.println("Failed to retrieve SAAS_SESSION token.");
        return null;
    }

    /**
     *查询组织
     * 【1】查询当前部门的下一级部门时，只设置 parentId 参数
     * 【2】查询当前部门的所有下级部门时，设置 parentId 参数和 includeLower 参数；
     * 部门模糊匹配时，设置 name 参数，同时根据需求按 「1」 或 「2」 的原则设置设置 parentId 参数和 includeLower 参数
     * 父组织编号，根目录的 parentId 为 -1
     * name[部门名称支持模糊搜索]
     */
    public String getDepartments() throws Exception {
        // 从 Redis 中获取 token
        String token = redisUtils.get(TOKEN_KEY);
        if (token == null) {
            throw new Exception("No valid token found in Redis.");
        }

        int parentId = -1;
        Boolean includeLower = true;
        String name = null;

        // 构建请求URL，包含父组织id和可选参数
        StringBuilder urlBuilder = new StringBuilder(ApiConfig.DOMAIN + ApiConfig.DEPARTMENTS_API);
        urlBuilder.append("?parentId=").append(parentId)
                .append("&includeLower=").append(includeLower);

        if (name != null && !name.isEmpty()) {
            urlBuilder.append("&name=").append(name);
        }

        // 设置请求头，包含动态获取的 token
        HashMap<String, String> headers = new HashMap<>();
        headers.put("Cookie", "SAAS_SESSION=" + token);
        headers.put("Content-Type", "application/json; charset=UTF-8");

        // 发送 GET 请求获取组织列表
        return HttpClientUtil.sendGetRequest(urlBuilder.toString(), headers);
    }
    /**
     *调用/api/v2/departments/{departmentId}/users接口获取所有用户列表
     */    // 获取所有部门的用户列表，并返回合并后的用户数据

    public List<JSONObject> getUsersFromAllDepartments() throws Exception {
        // 从 Redis 中获取 token
        String token = redisUtils.get(TOKEN_KEY);
        if (token == null) {
            throw new Exception("No valid token found in Redis.");
        }

        // 调用 getDepartments 获取部门列表
        String departmentsUrl = getDepartments();

        // 发送 GET 请求获取部门列表
        String departmentsResponse = departmentsUrl;
        System.out.println("查询组织列表接口响应: " + departmentsResponse);

        // 解析部门数据，提取 departmentId
        JSONObject jsonResponse = JSONObject.parseObject(departmentsResponse);
        JSONArray dataArray = jsonResponse.getJSONArray("data");

        // 如果没有数据，返回空列表
        if (dataArray == null || dataArray.isEmpty()) {
            System.out.println("No departments found.");
            return new ArrayList<>();
        }

        // 存储所有部门用户的集合
        List<JSONObject> allUsers = new ArrayList<>();

        // 遍历所有部门，获取 departmentId 列表
        for (int i = 0; i < dataArray.size(); i++) {
            JSONObject department = dataArray.getJSONObject(i);
            Long departmentId = department.getLong("id");

            // 构建用户查询接口的URL
            String usersUrl = ApiConfig.DOMAIN + ApiConfig.DEPARTMENTS_API +"/"+ departmentId + "/users?pageNo=1&pageSize=10";
            HashMap<String, String> headers = new HashMap<>();
            headers.put("Cookie", "SAAS_SESSION=" + token);
            headers.put("Content-Type", "application/json; charset=UTF-8");

            // 发送 GET 请求获取用户列表
            String usersResponse = HttpClientUtil.sendGetRequest(usersUrl, headers);
            // 解析用户列表响应
            JSONObject usersJson = JSONObject.parseObject(usersResponse);

            // 获取用户数据
            JSONArray usersData = usersJson.getJSONArray("data");
            if (usersData != null && !usersData.isEmpty()) {
                // 将每个部门的用户数据添加到总用户列表中
                allUsers.addAll(usersData.toJavaList(JSONObject.class));
            }
        }
        return allUsers;
    }


    // 调用点位列表接口
    public String getPointsList() throws Exception {
        int pageSize=10;
        // 从 Redis 中获取 token
        String token = getTokenFromRedis();
        if (token == null) {
            throw new Exception("No valid token found in Redis, please check if the token is refreshed.");
        }
        // 获取 areaId 列表
        List<String> areaIds = getAreaIdsFromAreasList();

        // 请求头信息，包含从 Redis 获取的 token
        HashMap<String, String> headers = new HashMap<>();
        headers.put("Cookie", "SAAS_SESSION=" + token);
        headers.put("Content-Type", "application/json; charset=UTF-8");
        // 数据存储
        List<JSONObject> allPointsData = new ArrayList<>();
        Set<Long> processedPointIds = new HashSet<>(); // 用于去重的 Set

        // 遍历每个 areaId
        for (String areaId : areaIds) {
            int pageNo = 1;
            boolean hasMoreData = true;

            while (hasMoreData) {
                // 构建 URL
                String pointsUrl = ApiConfig.DOMAIN + ApiConfig.POINTS_API
                        + "?pageNo=" + pageNo
                        + "&pageSize=" + pageSize
                        + "&areaId=" + areaId
                        + "&includeLowerArea=true";

                // 调用 API
                String response = HttpClientUtil.sendGetRequest(pointsUrl, headers);

                // 解析 JSON 响应
                JSONObject jsonResponse = JSON.parseObject(response);
                JSONArray dataArray = jsonResponse.getJSONArray("data");

                // 处理返回的 data 数组
                if (dataArray != null && !dataArray.isEmpty()) {
                    for (int i = 0; i < dataArray.size(); i++) {
                        JSONObject point = dataArray.getJSONObject(i);
                        Long pointId = point.getLong("pointId");

                        // 去重逻辑：如果 pointId 已存在，则跳过
                        if (processedPointIds.contains(pointId)) {
                            continue;
                        }

                        // 添加到结果列表和去重集合
                        processedPointIds.add(pointId);
                        allPointsData.add(point);
                    }
                }

                // 判断是否还有下一页
                int totalCount = jsonResponse.getIntValue("totalCount");
                hasMoreData = pageNo * pageSize < totalCount; // 判断是否需要继续请求下一页
                pageNo++;
            }
        }

        // 将去重后的数据封装回 JSON 对象并返回
        JSONObject resultJson = new JSONObject();
        resultJson.put("data", allPointsData); // 将列表作为 data 字段
        return resultJson.toJSONString(); // 返回 JSON 格式字符串
    }

    /**
     * 获取树形结构并遍历获取areaid
     * @return
     * @throws Exception
     */
    private List<String> getAreaIdsFromAreasList() throws Exception {
        String json = treeSearch();
        JSONObject jsonObject = JSON.parseObject(json); // 使用FastJSON解析JSON

        List<String> areaIds = new ArrayList<>();

        // 检查data字段是否存在
        if (!jsonObject.containsKey("data")) {
            throw new JSONException("Expected field 'data' not found in the JSON object.");
        }

        Object dataObject = jsonObject.get("data");

        // 根据 data 类型分别处理 JSONArray 和 JSONObject
        if (dataObject instanceof JSONArray) {
            // 如果是 JSONArray 类型，直接处理
            JSONArray dataArray = (JSONArray) dataObject;
            extractParentIds(dataArray, areaIds);

        } else if (dataObject instanceof JSONObject) {
            // 如果是 JSONObject 类型，将其放入单元素的 JSONArray 进行统一处理
            JSONObject dataObj = (JSONObject) dataObject;
            if ("AREA".equals(dataObj.getString("type"))) {
                areaIds.add(dataObj.getString("parentId"));
            }

            // 如果存在 children 字段，递归提取
            if (dataObj.containsKey("children")) {
                JSONArray childrenArray = dataObj.getJSONArray("children");
                extractParentIds(childrenArray, areaIds);
            }

        } else {
            throw new JSONException("Expected field 'data' to be a JSONArray or JSONObject but found: " + dataObject.getClass().getName());
        }
        return areaIds;
    }
    // 递归方法：提取所有type为"AREA"的parentId
    private void extractParentIds(JSONArray array, List<String> areaIds) {
        for (int i = 0; i < array.size(); i++) {
            JSONObject area = array.getJSONObject(i);
            String type = area.getString("type");
            if ("AREA".equals(type)) {
                String parentId = area.getString("parentId");
                areaIds.add(parentId);
            }

            // 如果有子节点，递归调用
            if (area.containsKey("children")) {
                JSONArray children = area.getJSONArray("children");
                if (children.size() > 0) {
                    extractParentIds(children, areaIds);
                }
            }
        }
    }

    // 获取区域列表
    public  String getAreasList() throws Exception {
        // 从 Redis 中获取 token
        String token = getTokenFromRedis();
        String areasUrl = ApiConfig.DOMAIN + ApiConfig.AREAS_API;

        // 请求头信息，包含动态获取的 token
        HashMap<String, String> headers = new HashMap<>();
        headers.put("Cookie", "SAAS_SESSION=" + token);
        headers.put("Content-Type", "application/json; charset=UTF-8");

        // 调用 GET 接口获取区域列表
        System.out.println("调用区域列表接口"+HttpClientUtil.sendGetRequest(areasUrl, headers));
        return HttpClientUtil.sendGetRequest(areasUrl, headers);
    }




    //获取点位截图
    //暂不使用
//    public  Object getThumbnails(int pageNo,int pageSize,long begin, long end, long pointID) throws Exception {
//        // 从 Redis 中获取 token
//        String token = getTokenFromRedis();
//        StringBuilder thumbnailUrl=new StringBuilder(ApiConfig.DOMAIN+"/api/v2/points/thumbnail?pageNo=" + pageNo);
//        thumbnailUrl.append("&pageSize=").append(pageSize);
//        thumbnailUrl.append("&begin=").append(begin);
//        thumbnailUrl.append("&end=").append(end);
//
//        thumbnailUrl.append("&pointId=").append(pointID);
//
//        HashMap<String, String> headers = new HashMap<>();
//
//        headers.put("Cookie", "SAAS_SESSION=" + token);
//        headers.put("Content-Type", "application/json; charset=UTF-8");
//
//        System.out.println("获取点位截图"+HttpClientUtil.sendGetRequest(thumbnailUrl.toString(), headers));
//        // 调用 GET 接口获取截图列表
//        return HttpClientUtil.sendGetRequest(thumbnailUrl.toString(), headers);
//    }


    /**
     *获取设备列表
     */



    // 调用 /api/v2/points/tree_search 接口 获取点位树形结构
    public String treeSearch() throws Exception {
        // 从 Redis 中获取 token
        String token = redisUtils.get(TOKEN_KEY);
        if (token == null || token.isEmpty()) {
            throw new Exception("No valid token found in Redis.");
        }
        System.out.println("Token retrieved: " + token);

        // 构建请求URL，处理可选参数
        StringBuilder treeSearchUrl = new StringBuilder(ApiConfig.DOMAIN + ApiConfig.TREE_SEARCH_API);
        // 打印构建的 URL
        System.out.println("Constructed URL: " + treeSearchUrl);

        // 设置请求头
        HashMap<String, String> headers = new HashMap<>();
        headers.put("Cookie", "SAAS_SESSION=" + token);
        headers.put("Content-Type", "application/json; charset=UTF-8");

        // 发送 GET 请求获取树形资源
        String response = HttpClientUtil.sendGetRequest(treeSearchUrl.toString(), headers);
        System.out.println("获取点位树形结构"+response);
      //  System.out.println("API response: " + response);

        if (response == null || response.isEmpty()) {
            throw new Exception("API returned empty response.");
        }

        return response;
    }


    /**
     * 查询点位算法能力列表，并统计数据条数
     */


    public int getAbilitiesByPointId() throws Exception {
        // 先调用之前的方法获取 catalogueIds
        String catalogueIds = treeSearch();
        // 解析返回的 JSON 数据
        JSONObject json = JSONObject.parseObject(catalogueIds);

        // 提取 data 数组
        JSONArray data = json.getJSONArray("data");
        // 存储所有提取到的 pointId
        List<Integer> pointIds = new ArrayList<>();
        extractPointIds(data, pointIds);


        // 从 Redis 中获取 token
        String token = redisUtils.get(TOKEN_KEY);
        if (token == null) {
            throw new Exception("No valid token found in Redis.");
        }

        int totalCount = 0;  // 用于累计所有请求返回的数据条数

        // 遍历 catalogueIds 集合
        for (Object catalogueId :data ) {
            // 将 catalogueId 赋值给 pointId
            Long pointId = Long.valueOf((String) catalogueId);

            // 构建请求URL，替换 pointId
            String abilitiesUrl = ApiConfig.DOMAIN + "/api/v2/ai/apps/points/" + pointId + "/abilities";

            // 设置请求头，包含动态获取的 token
            HashMap<String, String> headers = new HashMap<>();
            headers.put("Cookie", "SAAS_SESSION=" + token);
            headers.put("Content-Type", "application/json; charset=UTF-8");

            // 发送 GET 请求获取算法能力列表
            String response = HttpClientUtil.sendGetRequest(abilitiesUrl, headers);

            // 解析返回的 JSON 数据
            JSONObject jsonResponse = JSONObject.parseObject(response);

            // 提取 data 数组
            JSONArray dataArray = jsonResponse.getJSONArray("data");

            // 统计每个 pointId 的数据条数，并累加到 totalCount
            int count = dataArray != null ? dataArray.size() : 0;
            totalCount += count;
        }

        // 返回累计的总条数
        return totalCount;
    }
    // 递归提取 pointId 的方法
    private static void extractPointIds(JSONArray array, List<Integer> pointIds) {
        for (int i = 0; i < array.size(); i++) {
            JSONObject obj = array.getJSONObject(i);

            // 检查类型是否为 POINT
            if ("POINT".equals(obj.getString("type"))) {
                pointIds.add(obj.getInteger("id")); // 将 id 作为 pointId 添加到列表
            }

            // 如果有子节点，递归提取
            JSONArray children = obj.getJSONArray("children");
            if (children != null && !children.isEmpty()) {
                extractPointIds(children, pointIds);
            }
        }
    }

    /**
     * 提供查询目录列表的功能。该接口会根据用户权限控制返回的目录列表。
     */
    public List<Integer> getCatelogues() throws Exception {
        String token =redisUtils.get(TOKEN_KEY);
        if (token == null){
            throw new Exception("No valid token found in Redis.");
        }
        String url =ApiConfig.DOMAIN + ApiConfig.CATALOGUES_API;

        HashMap<String, String> headers = new HashMap<>();
        headers.put("Cookie", "SAAS_SESSION=" + token);
        headers.put("Content-Type", "application/json; charset=UTF-8");

        String response = HttpClientUtil.sendGetRequest(url, headers);
        System.out.println("获取目录列表"+response);

        JSONObject jsonResponse = JSONObject.parseObject(response);

        JSONArray dataArray = jsonResponse.getJSONArray("data");

        List<Integer> catalogueIds = new ArrayList<>();

        // 遍历data数组并将每个对象的catalogueId存入集合
        for (int i = 0; i < dataArray.size(); i++) {
            JSONObject item = dataArray.getJSONObject(i);
            Integer catalogueId = item.getInteger("catalogueId");

            // 将非空的catalogueId添加到集合中
            if (catalogueId != null) {
                catalogueIds.add(catalogueId);
            }
        }

        // 如果集合为空，抛出异常提示没有找到任何catalogueId
        if (catalogueIds.isEmpty()) {
            throw new Exception("No catalogueId found in the response.");
        }

        return catalogueIds;
    }


    /**
     * 查询设备列表
     */
    public String getDeviceList() throws Exception {
        // 从 Redis 中获取 token
        String token = redisUtils.get(TOKEN_KEY);
        if (token == null) {
            throw new Exception("No valid token found in Redis.");
        }

        // 构造设备列表 API 的 URL
        boolean includeLowerArea =true;
        // TODO填写根节点id获取所有数据
        Integer areaId=1002247;
        Integer pageSize = 10;
        Integer pageNum = 1;
        String deviceUrl = ApiConfig.DOMAIN + "/api/v2/devices"+"?includeLowerArea="+includeLowerArea+"&areaId="+areaId+"&pageSize="+pageSize+"&pageNum="+pageNum;
        System.out.println("Device URL: " + deviceUrl); // 打印 URL 确认正确性

        // 设置请求头，包含动态获取的 token
        HashMap<String, String> headers = new HashMap<>();
        headers.put("Cookie", "SAAS_SESSION=" + token);
        headers.put("Content-Type", "application/json; charset=UTF-8");

        // 发送 GET 请求获取设备列表
        String response = HttpClientUtil.sendGetRequest(deviceUrl, headers);
       // System.out.println("Response from device API: " + response); // 打印返回的内容

        // 解析返回的数据
        JSONObject jsonResponse = JSONObject.parseObject(response);
        return jsonResponse.toJSONString();
    }

    /**
     *
     * @param pointId 点位id
     * @param protocol 播放协议类型
     * @return
     * @throws Exception
     */
    public String getSignedUrlForPoint(long pointId, String protocol) throws Exception {
        // 从 Redis 中获取 token
        String token = getTokenFromRedis();
        if (token == null) {
            throw new Exception("No valid token found in Redis.");
        }

        // 构建请求URL
        String signedUrl = ApiConfig.DOMAIN + "/api/v2/points/" + pointId + "/signed_url?protocol=" + protocol;

        // 设置请求头，包含动态获取的 token
        HashMap<String, String> headers = new HashMap<>();
        headers.put("Cookie", "SAAS_SESSION=" + token);
        headers.put("Content-Type", "application/json; charset=UTF-8");

        // 调用 GET 接口获取播放链接
        return HttpClientUtil.sendGetRequest(signedUrl, headers);
    }


    /**
     * 获取配置算法的点位
     * 查询点位绑定算法能力列表
     * @return 反代带算法的所有点位列表
     * @throws Exception
     */
    public JSONArray getSuanfaPoints() throws Exception {
        String catalogueIds =treeSearch();
        JSONObject json = JSONObject.parseObject(catalogueIds);
        Object dataObject = json.get("data");
        JSONArray data;

        if (dataObject instanceof JSONArray) {
            data = (JSONArray) dataObject;
        } else if (dataObject instanceof JSONObject) {
            data = new JSONArray();
            data.add(dataObject);
        } else {
            throw new Exception("Expected 'data' to be either a JSONArray or JSONObject, but found: " +
                    (dataObject != null ? dataObject.getClass().getSimpleName() : "null"));
        }

        if (data.isEmpty()) {
            throw new Exception("No data found in catalogueIds JSON.");
        }

        String token = redisUtils.get(TOKEN_KEY);
        if (token == null) {
            throw new Exception("No valid token found in Redis.");
        }

        for (Object datum : data) {
            Long pointId;

            // 检查 datum 是否为 JSONObject 并提取所需的 ID 字段
            if (datum instanceof JSONObject) {
                JSONObject jsonObject = (JSONObject) datum;
                // 提取需要的 id 字段作为 pointId，确保是数值类型
                if (jsonObject.containsKey("id")) {
                    pointId = jsonObject.getLong("id");
                } else {
                    System.err.println("No valid 'id' found in JSON object: " + jsonObject);
                    continue; // 跳过无效数据
                }
            } else if (datum instanceof Integer) {
                pointId = ((Integer) datum).longValue();
            } else {
                try {
                    pointId = Long.valueOf(datum.toString());
                } catch (NumberFormatException e) {
                    System.err.println("Invalid format for pointId: " + datum);
                    continue; // 跳过无效数据
                }
            }

            String abilitiesUrl = ApiConfig.DOMAIN + "/api/v2/ai/apps/points/" + pointId + "/abilities";

            HashMap<String, String> headers = new HashMap<>();
            headers.put("Cookie", "SAAS_SESSION=" + token);
            headers.put("Content-Type", "application/json; charset=UTF-8");

            String response = HttpClientUtil.sendGetRequest(abilitiesUrl, headers);
            if (response == null || response.isEmpty()) {
                System.err.println("Failed to get response for pointId: " + pointId);
                continue;
            }

            JSONObject responseObject = JSONObject.parseObject(response);
            System.out.println("Response for pointId " + pointId + ": " + responseObject);
        }

        System.out.println("实时监控data=" + data);
        return data;
    }


    /**
     * 获取点位的位置信息
     */
    public String getPointPosition() throws Exception {
        int pageNo=1;
        int pageSize=10;
        // 从 Redis 中获取 token
        String token = getTokenFromRedis();
        if (token == null) {
            throw new Exception("No valid token found in Redis, please check if the token is refreshed.");
        }
        // 获取 areaId 列表
        List<String> areaIds = getAreaIdsFromAreasList();

        // 请求头信息，包含从 Redis 获取的 token
        HashMap<String, String> headers = new HashMap<>();
        headers.put("Cookie", "SAAS_SESSION=" + token);
        headers.put("Content-Type", "application/json; charset=UTF-8");

        StringBuilder result = new StringBuilder();

        // 遍历每个 areaId 构建 URL 并调用 API
        for (String areaId : areaIds) {
            String pointsUrl = ApiConfig.DOMAIN + ApiConfig.POINTS_API_Tags + "?pageNo=" + pageNo + "&pageSize=" + pageSize + "&areaId=" + areaId;
            String response = HttpClientUtil.sendGetRequest(pointsUrl, headers);
            result.append(response).append("\n"); // 将每个响应结果添加到结果中
        }
        System.out.println("点位接口【标签】"+result);
        return result.toString();

    }




}
